First value of the result: 0 Second value of the result: 14
Object references can be parameters. This works the same way as with primitive data: call by value is used, but now the value is a reference to an object. Since the invoked method has a reference to an object, it can use that object the same as any method. Here is an example program:
class ObjectPrinter { public void print( String st ) { System.out.println("Value of parameter: " + st ); } } class OPTester { public static void main ( String[] args ) { String message = "Only One Object" ; ObjectPrinter op = new ObjectPrinter(); System.out.println("First value of message: " + message ); op.print( message ); System.out.println("Second value of message: " + message ); } }